﻿@model Qu.SeniorProject.Model.Project

@section head {

    <link href="@Url.Content("~/Content/AwesomeLookup.css")" rel="stylesheet" type="text/css" />
	<style type="text/css">
        em { font-weight: bold; padding-right: 1em; vertical-align: top; color: red; }
        .text-box { width: 100%; }
        .text-box.multi-line {
            height: 8em;
        }
        
        .ae-lookup-multidisplay {
            border: 1px solid #AAAAAA;
            float: left;
            min-height: 18px;
            padding: 5px;
            width: 82%;
        }
        
@*        .ae-lookup-openbtn {
            float: left;
            margin-left: 3px;
            height: 30px;
            cursor: pointer;
        }*@
	</style>

       <script type="text/javascript">
           $(function () {
               $("#butValidateForm").click(function () {

                   var val = $('#myForm').validate();
                   val.showErrors();  //<-- Call showErrors
                   alert(val.valid());
               })
           });


//           $(document).ready(function () {
//               $("#lpoStudents").prepend('lookup');
//               $("#lpoStudents").width(60);
//           });

       </script>

@*   @if (!string.IsNullOrEmpty(ViewBag.Title) && ViewBag.Title == "Project Details")
   {
       <script type="text/javascript">

           $(document).ready(function () {
               $(':input').attr('disabled', 'disabled');
               $("#main").attr('disabled', 'disabled');
               $("#lpoStudents").remove();
               $('input[type=submit]').remove();
           });

       </script>
  }*@
  
     @if (ViewBag.IsStudent != null && ViewBag.IsStudent && Model.SupervisorID != null)
     {
       <script type="text/javascript">

           $(document).ready(function () {
               $("#lpoStudents").remove(); /*Do not allow students to edit the team for supervised projects */
               $("#CoSupervisorIDdropdown").attr('disabled', 'disabled');
               $("#SupervisorIDdropdown").attr('disabled', 'disabled');
           });

       </script>
     }
     else if (ViewBag.IsStudent != null && ViewBag.IsStudent)
     {
       <script type="text/javascript">

           $(document).ready(function () {
               $("#CoSupervisorIDdropdown").attr('disabled', 'disabled');
               $("#SupervisorIDdropdown").attr('disabled', 'disabled');
           });

       </script>
     }
     else 
     {
        <script type="text/javascript">
            $(document).ready(function () {
                $("#SupervisorIDdropdown").attr('disabled', 'disabled');
            });
       </script>
     }

@*    <script type="text/javascript">
            function deleteContainer(evt) {
                evt = evt || window.event;
                var target = evt.target || evt.srcElement;
                target.parentNode.parentNode.removeChild(target.parentNode);
            }
    </script>

    <script type="text/javascript">
    $(document).ready(function () {
        $("input#student").autocomplete({
                source: function (request, response) {
                    // define a function to call your Action (assuming UserController)
                    $.ajax({
                        url: '/Home/GetStudents', type: "POST", dataType: "json",

                        // query will be the param used by your action method
                        data: { query: request.term },
                        success: function (data) {
                            response($.map(data, function (item) {
                                return { label: item, value: item };
                            }))
                        }
                    })
                },
                minLength: 4, // require at least one character from the user
            }); 
        });
    </script>*@
}

@*@{
    ViewBag.Title = "Add Project";
}*@

@if (!string.IsNullOrEmpty(ViewBag.Message))
{
    <h2>@ViewBag.Message</h2>
    <br />                  
                                                        
    <div>
        @Html.ActionLink("Back to Home", "Index")
    </div>
   return;
}  


<h2>@ViewBag.Title</h2>

@using (Html.BeginForm())
{
    @Html.HiddenFor(model => model.ProjectId)
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Project Details</legend>

        <table>
            <tr>
                <td style="width:50%;">
                    <div class="editor-label">
                        @Html.LabelFor(model => model.ProjectTitle)<em>*</em>
                    </div>
                    <div class="editor-field">
                        @Html.TextBoxFor(model => model.ProjectTitle, new { @maxlength = "250", @style = "width:98%;" })
                    </div>
                    <br /> @Html.ValidationMessageFor(model => model.ProjectTitle)
                </td>
                <td style="width:70px">Students :</td>
                <td>@Html.Lookup("Students", Model.StudentIDs, multiselect: true, fullscreen: true, title: "Search Student by StudentID or Student Name then Click the + button or drag the item to add")</td>
            </tr>
        </table>

        <div class="editor-label">
            @Html.LabelFor(model => model.ProjectDescription)<em>*</em>
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.ProjectDescription)
            <br /> @Html.ValidationMessageFor(model => model.ProjectDescription)
        </div>

@*        @Html.HiddenFor(model => model.Supervisor)
        @Html.HiddenFor(model => model.SupervisorID) style="border:0px solid white";
*@

        <br />
        <table>
            <tr>
                <td width="140px" >Supervisor: </td> 
                <td>@Html.AjaxDropdown("SupervisorID", controller: "SupervisorAjaxDropdown")</td>

                <td width="100px" >CoSupervisor: </td> 
                <td>@Html.AjaxDropdown("CoSupervisorID", controller: "SupervisorAjaxDropdown")</td>
            </tr>
            <tr >
                <td width="140px" >In collaboration with: </td>
                <td colspan='3'>
                    <span class="editor-field">
                          @Html.DropDownListFor(model => model.InCollaborationWith, ((SelectList)ViewBag.InCollaborationWithList).Select(option => new SelectListItem
                          {
                                Text = (option == null ? "None" : option.Text),
                                Value = option.Value.ToString(),
                                Selected = (Model != null) && (option.Value == Model.InCollaborationWith)
                          }), "", 
                          new Dictionary<string, object>
                          {
                             {"id", "InCollaborationWithDropDown"}
                          })
                          @*@Html.ValidationMessageFor(model => model.InCollaborationWith, "*")*@
                    </span>
                </td>
            </tr>
        </table>


       <fieldset id="CollaboratorDetails">
           <legend>Collaborator Details</legend>
           <table >
                <tr>
                    <td style="width:50%;">
                        <div class="editor-label">
                           Organization Name<em>*</em>
                        </div>
                        <div class="editor-field">
                            @Html.TextBoxFor(model => model.CollaboratorOrganization, new { @maxlength = "100", @style = "width:98%;" })
                        </div>
                        <br /> @Html.ValidationMessageFor(model => model.CollaboratorOrganization)
                    </td>
                    <td colspan='2'>
                        <div class="editor-label">
                           Contact Name<em>*</em>
                        </div>
                        <div class="editor-field">
                            @Html.TextBoxFor(model => model.CollaboratorContactName, new { @maxlength = "100", @style = "width:98%;" })
                        </div>
                        <br /> @Html.ValidationMessageFor(model => model.CollaboratorContactName)
                    </td>
                </tr>
               <tr>
                    <td style="width:50%;">
                        <div class="editor-label">
                           Contact Email<em>*</em>
                        </div>
                        <div class="editor-field">
                            @Html.TextBoxFor(model => model.CollaboratorContactEmail, new { @maxlength = "50", @style = "width:98%;" })
                        </div>
                        <br /> @Html.ValidationMessageFor(model => model.CollaboratorContactEmail)
                    </td>
                    <td style="width:25%;">
                        <div class="editor-label">
                           Phone<em>*</em>
                        </div>
                        <div class="editor-field">
                            @Html.TextBoxFor(model => model.CollaboratorContactPhone, new { @maxlength = "50", @style = "width:98%;" })
                        </div>
                        <br /> @Html.ValidationMessageFor(model => model.CollaboratorContactPhone)
                    </td>
                    <td style="width:25%;">
                        <div class="editor-label">
                             Mobile
                        </div>
                        <div class="editor-field">
                            @Html.TextBoxFor(model => model.CollaboratorContactMobile, new { @maxlength = "50", @style = "width:98%;" })
                        </div>
                        <br /> @Html.ValidationMessageFor(model => model.CollaboratorContactMobile)
                    </td>
                </tr>
            </table>
        </fieldset>
        @Html.HiddenFor(model => model.PeriodId)

        @*@Html.EditorFor(model => model.CoSupervisorID)*@


@*        @Html.HiddenFor(model => model.PeriodId)
        @Html.HiddenFor(model => model.Status)
        @Html.HiddenFor(model => model.SponsorOrganization)
        @Html.HiddenFor(model => model.SponsorContactName)
        @Html.HiddenFor(model => model.SponsorContactEmail)
        @Html.HiddenFor(model => model.SponsorContactPhone)

        @Html.HiddenFor(model => model.RelatedProjectId)
        @Html.HiddenFor(model => model.PresentationOrder)
        @Html.HiddenFor(model => model.ProposalPresentationTime)
        @Html.HiddenFor(model => model.Comment)
        @Html.HiddenFor(model => model.ReviewFeedback)*@

        <div class="editor-label">
            @Html.LabelFor(model => model.ProjectTasks)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.ProjectTasks)
            @Html.ValidationMessageFor(model => model.ProjectTasks)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.SkillsRequired)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.SkillsRequired)
            @Html.ValidationMessageFor(model => model.SkillsRequired)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.ResourcesNeeded)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.ResourcesNeeded)
            @Html.ValidationMessageFor(model => model.ResourcesNeeded)
        </div>

        @* @Html.HiddenFor(model => model.ProposalURL) *@



@*       @Html.EditorFor(model => model.StudentIDs)

        <fieldset>
            <legend>Students</legend>
            <div id="students">

            </div>

            @Ajax.ActionLink("Add another student", "StudentInfo", new AjaxOptions
            {
                    UpdateTargetId = "students", InsertionMode = InsertionMode.InsertAfter
            })

          </fieldset>*@
          <p>
                @*<input type="submit" value="@ViewBag.Title" />*@
                <input type="submit" value="Submit" />
          </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to Home", "Index")
</div>
